<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <h2><span id="sp">5</span>秒后返回主页</h2>
    <script>
        var num = 5;
        setInterval(function () {
            num = num-1;
            document.getElementById("sp").innerText = num;
            if (num ==1){
                location.href = "http://www.baidu.com";
            }
        },1000);


    </script>
</body>
</html>